package com.biye.auth.service.impl;

import com.base.common.edu.entity.LoginFail;
import com.base.common.edu.entity.Staff;
import com.base.common.edu.entity.Student;
import com.base.common.edu.mapper.LoginFailMapper;
import com.base.common.edu.mapper.StaffMapper;
import com.base.common.edu.mapper.StudentMapper;
import com.biye.auth.service.UserLoginService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class UserLoginServiceImpl implements UserLoginService {

    @Resource
    private StudentMapper studentMapper;

    @Resource
    private StaffMapper staffMapper;

    @Resource
    private LoginFailMapper loginFailMapper;

    @Override
    public Student stuLogin(String sno, String password) {
        return this.studentMapper.studentLogin(sno, password);
    }

    @Override
    public Staff staffLogin(String tno, String password) {
        return this.staffMapper.staffLogin(tno, password);
    }

    @Override
    public List<LoginFail> queryLoginFail(LoginFail loginFail) {
        return this.loginFailMapper.queryLoginFailRecords(loginFail);
    }

    @Override
    public int saveLoginFail(LoginFail loginFail) {
        return this.loginFailMapper.addLoginFail(loginFail);
    }

    @Override
    public int queryLoginFailByUserAndIp(String user__name, String ip__address) {
        return this.loginFailMapper.queryLoginFailByUserAndIp(user__name, ip__address);
    }

    @Override
    public List<Staff> queryStaff(Staff staff) {
        return this.staffMapper.queryStaff(staff);
    }

    @Override
    public int updateSatff(Staff staff) {
        return this.staffMapper.updateSatff(staff);
    }

    @Override
    public List<Student> queryStudents(Student student) {
        return this.studentMapper.queryStudents(student);
    }

    @Override
    public int updateStudent(Student student) {
        return this.studentMapper.updateStudent(student);
    }

    @Override
    public Staff staffLoginUseEmail(String email, String passwd) {
        return this.staffMapper.staffLoginUseEmail(email, passwd);
    }

    @Override
    public Student studentLoginUseEmail(String email, String passwd) {
        return this.studentMapper.studentLoginUseEmail(email, passwd);
    }


}
